/***************************************************************************
 创建者: 华磊
 开始时间: 2018.8.14
 copyright: (C) 华友高科
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) hualei 2017.5.8 类的具体实现代码编写

 ***************************************************************************/
#include "reginstructionlogic.h"
#include "GeneralDefine.h"
#include "programengine.h"
#include "messagelog.h"
#include "globalregister.h"

extern GlobalRegister *g_globalRegister;

RegInstructionLogic::RegInstructionLogic(int robotIdIn, ProgramSet* programSetIn, RobotIo* ioControllerIn
                                         , ProgramEngine* programEngineIn
                                         , RegData *regDataIn, McControllerThread *programMcControllerIn)
{
  programSet=programSetIn;
  robotId=robotIdIn;
  ioController=ioControllerIn;
  programEngine=programEngineIn;
  regData=regDataIn;
  programMcController=programMcControllerIn;

}

E_PROGRAM_LOOP_RESULT RegInstructionLogic::startReg(int programNum,
                                         RegisterInstruction registerInstruct)
{
    programEngine->updateProgramSetRegister();

    E_PROGRAM_LOOP_RESULT endFlag = E_PROGRAM_LOOP_RESULT_NORMAL;


    switch(registerInstruct.type)
    {
    case REG_GR:
    {
        return startGlobalReg(programNum,registerInstruct);
    }
    case REG_INS:
    {
        switch(registerInstruct.addressType)
        {
        case DIRECT:
        {
//            qDebug() << "=====direct=="<<"====i=="<<registerInstruct.i<<"====regData->regRValue.size()==="<<regData->regRValue.size()<<"\n\n\n\n";
            if((D_ROBOT_REG_SIZE < (int)registerInstruct.i) || (programSet->regRList.size() < (int)registerInstruct.i)
                    ||(1 > registerInstruct.i))
            {
                programEngine->cmdError(programNum);
                addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId );
                return E_PROGRAM_LOOP_RESULT_ERROR;
            }
            else
            {
                programSet->regRList[(int)registerInstruct.i - 1] = programEngine->parseRegisterData(programNum);
                qDebug() << __FUNCTION__<<"***line***"<<__LINE__<<"====registerInstruct.i===="
                         <<registerInstruct.i<<"==r="<<programSet->regRList[(int)registerInstruct.i - 1]
                        <<"==threadId===="<<QThread::currentThreadId()<<endl;
                regData->setRRegValue((int)registerInstruct.i -1,programSet->regRList[(int)registerInstruct.i - 1]);
            }

        }
            break;
        case INDIRECT:
        {
            if((D_ROBOT_REG_SIZE < (int)registerInstruct.i)
                    || (D_ROBOT_REG_SIZE < (int)programSet->regRList[(int)registerInstruct.i - 1])
                    ||(programSet->regRList.size() < (int)registerInstruct.i)
                            || (programSet->regRList.size() < (int)programSet->regRList[(int)registerInstruct.i - 1])
                    ||(1 > registerInstruct.i) ||(1 > programSet->regRList[(int)registerInstruct.i - 1]))
            {
                programEngine->cmdError(programNum);
                addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId );
                return E_PROGRAM_LOOP_RESULT_ERROR;
            }
            else
            {
                programSet->regRList[(int)programSet->regRList[(int)registerInstruct.i - 1] - 1] = programEngine->parseRegisterData(programNum);
                regData->setRRegValue((int)programSet->regRList[(int)registerInstruct.i - 1],programSet->regRList[(int)programSet->regRList[(int)registerInstruct.i - 1]- 1]);
            }
        }
            break;
        }
    }
        break;
    case POS_REG_INS://PR[i]
    {
        switch (registerInstruct.addressType)
        {
        case DIRECT:
        {
            if((D_ROBOT_REG_SIZE < (int)registerInstruct.i)
                    || (programSet->regPrList.size() < (int)registerInstruct.i)
                    ||(1 > registerInstruct.i))
            {
                programEngine->cmdError(programNum);
                addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId );
                return E_PROGRAM_LOOP_RESULT_ERROR;
            }
            else
            {
                programSet->regPrList[(int)registerInstruct.i - 1] = programEngine->parsePRData(programNum);
                regData->setPrRegValue((int)registerInstruct.i - 1,programSet->regPrList[(int)registerInstruct.i - 1]);
            }
        }
            break;
        case INDIRECT:
        {
            if((D_ROBOT_REG_SIZE < (int)registerInstruct.i)
                    ||(D_ROBOT_REG_SIZE < (int)programSet->regRList[(int)registerInstruct.i - 1])
                    ||(programSet->regPrList.size() < (int)registerInstruct.i)
                            ||(programSet->regPrList.size() < (int)programSet->regRList[(int)registerInstruct.i - 1])
                    ||( 1 > registerInstruct.i) ||(1 > programSet->regRList[(int)registerInstruct.i - 1]))

            {
                programEngine->cmdError(programNum);
                addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId );
                return E_PROGRAM_LOOP_RESULT_ERROR;
            }
            else
            {
                programSet->regPrList[(int)programSet->regRList[(int)registerInstruct.i - 1] - 1] = programEngine->parsePRData(programNum);
                regData->setPrRegValue((int)programSet->regRList[(int)registerInstruct.i - 1],programSet->regPrList[(int)programSet->regRList[(int)registerInstruct.i -1] -1]);
            }
        }
            break;
        }
    }
        break;
    case POS_REG_AXIS_INS://PR[i,j]
    {
        switch (registerInstruct.addressType)
        {
        case DIRECT:
        {
//            qDebug() << __FUNCTION__ << "===i====="<<registerInstruct.i<<"====j==="<<registerInstruct.j
//                     <<"===size=="<<programSet->regPrList[(int)registerInstruct.i - 1].positionValue.size()<<"\n\n";
            if((D_ROBOT_REG_SIZE < (int)registerInstruct.i)
                    || programSet->regPrList[(int)registerInstruct.i - 1].positionValue.size() < (int)registerInstruct.j
                    || (1 > registerInstruct.i) ||(1 >registerInstruct.j))
            {
                programEngine->cmdError(programNum);
                addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId );
                return E_PROGRAM_LOOP_RESULT_ERROR;
            }
            else
            {
                programSet->regPrList[(int)registerInstruct.i - 1].positionValue[(int)registerInstruct.j -1] = programEngine->parseRegisterData(programNum);
                regData->setPrIJValue( (int)registerInstruct.i -1, (int)registerInstruct.j - 1,  programSet->regPrList[(int)registerInstruct.i - 1].positionValue[(int)registerInstruct.j -1] );
            }
         }
            break;
            //                case INDIRECT:
            //                {
            //                    programSet->regPrList[(int)registerInstruct.i][(int)registerInstruct.j] = programEngine->parseRegisterData(programNum);
            //                }
            //                break;
        }
    }
        break;
    case AR_PAL_REG_INS://PL[i]
    {
        switch (registerInstruct.addressType)
        {
        case DIRECT:
        {
            if((PL_SIZE < (int)registerInstruct.i) || (1 > registerInstruct.i))
            {
                programEngine->cmdError(programNum);
                addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId );
                return E_PROGRAM_LOOP_RESULT_ERROR;
            }
            else
            {
                programSet->plList[(int)registerInstruct.i - 1] = programEngine->parsePLData(programNum);
//                qDebug() << __LINE__<<"===programSet->plList=="<<programSet->plList[(int)registerInstruct.i - 1];
                PlRegStruct tmpPlReg;
                tmpPlReg.row = programSet->plList[(int)registerInstruct.i - 1][0];
                tmpPlReg.col = programSet->plList[(int)registerInstruct.i - 1][1];
                tmpPlReg.layer = programSet->plList[(int)registerInstruct.i - 1][2];
                programSet->regPlList[(int)registerInstruct.i - 1] = tmpPlReg;
                if(programSet->regPlList.size() <= (int)registerInstruct.i)
                {
                    programEngine->cmdError(programNum);
                    addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId );
                    return E_PROGRAM_LOOP_RESULT_ERROR;
                }
                else
                {
                    if(programEngine->isMainThreadTrue())
                    {
                        regData->setPlRegValue((int)registerInstruct.i - 1,tmpPlReg);
                        programMcController->mcControllerInterpreter->setPalletPlFlag(registerInstruct.i);
                    }
                    else
                    {
                        programEngine->cmdError(programNum);
                        addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3021, robotId );
                        return E_PROGRAM_LOOP_RESULT_ERROR;
                    }
                }
            }
        }
            break;
        case INDIRECT:
        {
            if((D_ROBOT_REG_SIZE < (int)registerInstruct.i) ||(PL_SIZE <= (int)programSet->regRList[(int)registerInstruct.i - 1])
                    ||(1 > registerInstruct.i) ||(1 > programSet->regRList[(int)registerInstruct.i - 1]))
            {
                programEngine->cmdError(programNum);
                addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId );
                return E_PROGRAM_LOOP_RESULT_ERROR;
            }
            else
            {
                programSet->plList[(int)programSet->regRList[(int)registerInstruct.i - 1] - 1] = programEngine->parsePLData(programNum);
                PlRegStruct tmpPlReg;
                tmpPlReg.row = programSet->plList[(int)programSet->regRList[(int)registerInstruct.i - 1] -1][0];
                tmpPlReg.col = programSet->plList[(int)programSet->regRList[(int)registerInstruct.i - 1] -1][1];
                tmpPlReg.layer = programSet->plList[(int)programSet->regRList[(int)registerInstruct.i - 1] -1][2];
                programSet->regPlList[(int)programSet->regRList[(int)registerInstruct.i - 1] - 1] = tmpPlReg;
                if(programSet->regPlList.size() <= (int)programSet->regRList[(int)registerInstruct.i])
                {
                    programEngine->cmdError(programNum);
                    addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId );
                    return E_PROGRAM_LOOP_RESULT_ERROR;
                }
                else
                {
                    if(programEngine->isMainThreadTrue())
                    {
                        regData->setPlRegValue((int)programSet->regRList[(int)registerInstruct.i - 1],tmpPlReg);
                        programMcController->mcControllerInterpreter->setPalletPlFlag(registerInstruct.i);
                    }
                    else
                    {
                        programEngine->cmdError(programNum);
                        addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3021, robotId );
                        return E_PROGRAM_LOOP_RESULT_ERROR;
                    }
                }
            }
        }
            break;
        }
    }
        break;
    case STR_REG://SR[i]
    {
        switch (registerInstruct.addressType)
        {
        case DIRECT:
        {

        }
            break;
        case INDIRECT:
        {

        }
            break;
        }
    }
        break;
    }


//    qDebug() << "====r3===" <<programSet->r[3]<<endl;
    programEngine->calculateNextLineToRun(programNum);

    endFlag = programEngine->isTheLastInstruction(programNum);
    return endFlag;
}

E_PROGRAM_LOOP_RESULT RegInstructionLogic::startPrReg(int programNum, const PrRegisterInstruction &prRegisterInstruction)
{
    programEngine->updateProgramSetRegister();

    E_PROGRAM_LOOP_RESULT endFlag = E_PROGRAM_LOOP_RESULT_NORMAL;

    //
    switch(prRegisterInstruction.instructionType)
    {
    case E_PR_INS_TYPE_PRIJ_CONST:
    {
        int returnKey=regData->setPrIJValue(prRegisterInstruction.left_index_i-1,
                                            prRegisterInstruction.left_index_j-1,prRegisterInstruction.constValue);

        if(1!=returnKey)
        {
            programEngine->cmdError(programNum);
            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.left_index_i );
            return E_PROGRAM_LOOP_RESULT_ERROR;
        }
        break;
    }
//    case E_PR_INS_TYPE_PRIJ_PRIJ:
//    {
//         double tmpNewValue;
//        int returnKey=regData->getPrValue_ij(prRegisterInstruction.right_index_i-1,
//                                             prRegisterInstruction.right_index_j-1,tmpNewValue);

//        if(1!=returnKey)
//        {
//            programEngine->cmdError(programNum);
//            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.right_index_i);
//            return E_PROGRAM_LOOP_RESULT_ERROR;
//        }


//        if(1==prRegisterInstruction.right_operate1)
//        {

//        }
//        else
//        {
//            tmpNewValue=-tmpNewValue;

//        }
//        returnKey=regData->setPrIJValue(prRegisterInstruction.left_index_i-1,
//                                            prRegisterInstruction.left_index_j-1,tmpNewValue);

//        if(1!=returnKey)
//        {
//            programEngine->cmdError(programNum);
//            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.left_index_i );
//            return E_PROGRAM_LOOP_RESULT_ERROR;
//        }
//        break;
//    }
    case E_PR_INS_TYPE_PRIJ_MINUS_PRIJ:
    {

        double tmpNewValue;
       int returnKey=regData->getPrValue_ij(prRegisterInstruction.right_index_i-1,
                                            prRegisterInstruction.right_index_j-1,tmpNewValue);

       if(1!=returnKey)
       {
           programEngine->cmdError(programNum);
           addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.right_index_i);
           return E_PROGRAM_LOOP_RESULT_ERROR;
       }


       if(1==prRegisterInstruction.right_operate1)
       {

       }
       else
       {
           tmpNewValue=-tmpNewValue;

       }

       //
       double tmpNewValue2;
      returnKey=regData->getPrValue_ij(prRegisterInstruction.right2_index_i-1,
                                           prRegisterInstruction.right2_index_j-1,tmpNewValue2);

      if(1!=returnKey)
      {
          programEngine->cmdError(programNum);
          addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.right2_index_i);
          return E_PROGRAM_LOOP_RESULT_ERROR;
      }


      if(1==prRegisterInstruction.right_operate2)
      {

      }
      else
      {
          tmpNewValue2=-tmpNewValue2;

      }
      tmpNewValue2=tmpNewValue2+tmpNewValue;

       returnKey=regData->setPrIJValue(prRegisterInstruction.left_index_i-1,
                                           prRegisterInstruction.left_index_j-1,tmpNewValue2);

       if(1!=returnKey)
       {
           programEngine->cmdError(programNum);
           addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.left_index_i );
           return E_PROGRAM_LOOP_RESULT_ERROR;
       }
       break;
    }
    case E_PR_INS_TYPE_PRIJ_MINUS_CONST:
    {

        double tmpNewValue;
       int returnKey=regData->getPrValue_ij(prRegisterInstruction.right_index_i-1,
                                            prRegisterInstruction.right_index_j-1,tmpNewValue);

       if(1!=returnKey)
       {
           programEngine->cmdError(programNum);
           addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.right_index_i);
           return E_PROGRAM_LOOP_RESULT_ERROR;
       }


       if(1==prRegisterInstruction.right_operate1)
       {

       }
       else
       {
           tmpNewValue=-tmpNewValue;

       }

       //
       double tmpNewValue2;
      tmpNewValue2=tmpNewValue+prRegisterInstruction.constValue;

       returnKey=regData->setPrIJValue(prRegisterInstruction.left_index_i-1,
                                           prRegisterInstruction.left_index_j-1,tmpNewValue2);

       if(1!=returnKey)
       {
           programEngine->cmdError(programNum);
           addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.left_index_i );
           return E_PROGRAM_LOOP_RESULT_ERROR;
       }
       break;
    }
    case E_PR_INS_TYPE_PRI_PRI:
    {
        PointPro tmppointPro;
        int returnKey=regData->getPrValue(prRegisterInstruction.right_index_i-1,tmppointPro);

        if(1!=returnKey)
        {
            programEngine->cmdError(programNum);
            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.right_index_i);
            return E_PROGRAM_LOOP_RESULT_ERROR;
        }

        if(1==prRegisterInstruction.right_operate1)
        {
            returnKey=regData->setPrRegValue(prRegisterInstruction.left_index_i-1,tmppointPro);
            if(1!=returnKey)
            {
                programEngine->cmdError(programNum);
                addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.left_index_i );
                return E_PROGRAM_LOOP_RESULT_ERROR;
            }
        }
        else
        {
            for(int i=0;i<tmppointPro.positionValue.size();i++)
            {
                tmppointPro.positionValue[i]=-tmppointPro.positionValue[i];
            }

            returnKey=regData->setPrRegValue(prRegisterInstruction.left_index_i-1,tmppointPro);
            if(1!=returnKey)
            {
                programEngine->cmdError(programNum);
                addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.left_index_i );
                return E_PROGRAM_LOOP_RESULT_ERROR;
            }
        }
        break;
    }
    case E_PR_INS_TYPE_PRI_MINUS_PRI:
    {

        //第一操作数
        PointPro tmppointPro;
        int returnKey=regData->getPrValue(prRegisterInstruction.right_index_i-1,tmppointPro);

        if(1!=returnKey)
        {
            programEngine->cmdError(programNum);
            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.right_index_i);
            return E_PROGRAM_LOOP_RESULT_ERROR;
        }

        if(1==prRegisterInstruction.right_operate1)
        {

        }
        else
        {
            for(int i=0;i<tmppointPro.positionValue.size();i++)
            {
                tmppointPro.positionValue[i]=-tmppointPro.positionValue[i];
            }

        }
        //第2操作数
        PointPro tmppointPro2;
        returnKey=regData->getPrValue(prRegisterInstruction.right2_index_i-1,tmppointPro2);

        if(1!=returnKey)
        {
            programEngine->cmdError(programNum);
            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.right2_index_i);
            return E_PROGRAM_LOOP_RESULT_ERROR;
        }

        if(1==prRegisterInstruction.right_operate2)
        {

        }
        else
        {
            for(int i=0;i<tmppointPro2.positionValue.size();i++)
            {
                tmppointPro2.positionValue[i]=-tmppointPro2.positionValue[i];
            }
        }

        if(tmppointPro2.positionValue.size()!=tmppointPro.positionValue.size())
        {
            programEngine->cmdError(programNum);
            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3022, robotId);
            return E_PROGRAM_LOOP_RESULT_ERROR;
        }
        else
        {
            for(int i=0;i<tmppointPro2.positionValue.size();i++)
            {
                tmppointPro2.positionValue[i]=tmppointPro2.positionValue[i]+tmppointPro.positionValue[i];
            }
        }
        //
        returnKey=regData->setPrRegValue(prRegisterInstruction.left_index_i-1,tmppointPro2);
        if(1!=returnKey)
        {
            programEngine->cmdError(programNum);
            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.left_index_i );
            return E_PROGRAM_LOOP_RESULT_ERROR;
        }
        break;
    }
    case E_PR_INS_TYPE_PRI_LPS:
    {

        //第一操作数
        PointPro tmppointPro;
        programMcController->mcControllerInterpreter->getCurrentCoordinatePoint_Feedback(tmppointPro);


        //
        int returnKey=regData->setPrRegValue(prRegisterInstruction.left_index_i-1,tmppointPro);
        if(1!=returnKey)
        {
            programEngine->cmdError(programNum);
            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.left_index_i );
            return E_PROGRAM_LOOP_RESULT_ERROR;
        }
        break;
    }
    case E_PR_INS_TYPE_PRI_JPS:
    {

        //第一操作数
        PointPro tmppointPro;
        programMcController->mcControllerInterpreter->getCurrentJointPoint_Feedback(tmppointPro);

        //
        int returnKey=regData->setPrRegValue(prRegisterInstruction.left_index_i-1,tmppointPro);
        if(1!=returnKey)
        {
            programEngine->cmdError(programNum);
            addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3017, robotId,prRegisterInstruction.left_index_i );
            return E_PROGRAM_LOOP_RESULT_ERROR;
        }
        break;
    }


    }

    programEngine->calculateNextLineToRun(programNum);

    endFlag = programEngine->isTheLastInstruction(programNum);
    return endFlag;

}

E_PROGRAM_LOOP_RESULT RegInstructionLogic::startPlReg(int programNum, const PlRegisterInstruction &plRegisterInstruction)
{
    QRegExp rxPl("\\[(\\d+),(\\d+),(\\d+)\\]");
    if(rxPl.exactMatch(plRegisterInstruction.valueExpress))
    {
        PlRegStruct plRegStruct;
        plRegStruct.row=rxPl.cap(1).toInt();
        plRegStruct.col=rxPl.cap(2).toInt();
        plRegStruct.layer=rxPl.cap(3).toInt();
        regData->setPlRegValue(plRegisterInstruction.plIndex-1,plRegStruct);

    }
    else
    {
        addMsg( ENUM_MSG_ERROR, "ProgramEngine", "ProgramEngine",  3023, robotId );
        return E_PROGRAM_LOOP_RESULT_ERROR;
    }


    programEngine->calculateNextLineToRun(programNum);

    return programEngine->isTheLastInstruction(programNum);

}

E_PROGRAM_LOOP_RESULT RegInstructionLogic::startGlobalReg(int programNum,RegisterInstruction registerInstruct)
{

    E_PROGRAM_LOOP_RESULT endFlag = E_PROGRAM_LOOP_RESULT_NORMAL;
    programEngine->calculateNextLineToRun(programNum);

    g_globalRegister->saveRegRValue(registerInstruct.i-1,registerInstruct.source_constantValue);

    endFlag = programEngine->isTheLastInstruction(programNum);
    return endFlag;
}



void RegInstructionLogic::addMsg(int messageLevel, string componentName, string messageType,
                           int messageCode, int robotId,
                           int parameter1, int parameter2, int parameter3, int parameter4,QString message)
{
    Message tmpMsg;
    tmpMsg.MessageLevel = messageLevel;
    tmpMsg.componentClassName = componentName;
    tmpMsg.messageType = messageType;
    tmpMsg.robotId = robotId;
    tmpMsg.messageCode = messageCode;
   // tmpMsg.time = t1.tv_sec;


    QString infomationStr;

    switch(messageCode)
    {
    case 3023:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr("; PL寄存器操作值不识别");
        break;

    }
    case 3022:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr("; PR寄存器的数据长度不一致，无法进行加减操作");
        break;

    }
    case 3017:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr(",寄存器指令错误，寄存器%1的范围超过限定的最大范围，请修改").arg(parameter1);
    }
        break;
    case 3021:
    {
        infomationStr =  QObject::tr("机器人:")  + QString::number(robotId);
        infomationStr = infomationStr + QObject::tr("; run 调用的文件中不能带有PL指令");

    }
        break;



    default:
    {

    }
    }


    tmpMsg.MessageInformation = infomationStr.toStdString();

    // qDebug()<<"53444444444444444444444"<< tmpMsg.messageCode;
    MessageLog::getInstance()->addMessage(tmpMsg);
}
